﻿Imports System.Xml

Public Class TextWrapPreference

	Property Inverse As Boolean

	Property ApplyToMasterPageOnly As Boolean

	Property TextWrapSide As TextWrapSideOptions

	Property TextWrapMode As TextWrapModes

	Property TextWrapOffset As TextWrapOffset

	Public Shared Function ReadXml(reader As XmlReader) As TextWrapPreference
		Dim twp As New TextWrapPreference()

		If reader.HasAttributes Then
			twp.Inverse = CBool(reader.GetAttribute("Inverse"))
			twp.ApplyToMasterPageOnly = CBool(reader.GetAttribute("ApplyToMasterPageOnly"))
			twp.TextWrapSide = [Enum].Parse(GetType(TextWrapSideOptions), reader.GetAttribute("TextWrapSide"))
			twp.TextWrapMode = [Enum].Parse(GetType(TextWrapModes), reader.GetAttribute("TextWrapMode"))
		End If

		While reader.Read()
			If reader.Name = "TextWrapOffset" And reader.NodeType = XmlNodeType.Element Then
				twp.TextWrapOffset = TextWrapOffset.ReadXml(reader)
			ElseIf reader.Name = "TextWrapPreference" And reader.NodeType = XmlNodeType.EndElement Then
				Exit While
			End If
		End While

		Return twp
	End Function
End Class